package com.shelpe.services.scheduler.item.keyword;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.beans.factory.annotation.Autowired;

import com.shelpe.services.scheduler.dto.KeywordsDto;
import com.shelpe.services.scheduler.po.Adgroups;
import com.shelpe.services.scheduler.po.SyncLog;
import com.shelpe.services.scheduler.syncclient.KeywordClient;
import com.shelpe.services.scheduler.util.Util;

public class FilterKeywordProcessor implements ItemProcessor<Adgroups, SyncLog>{

	
	private static final Logger logger = LoggerFactory.getLogger(FilterKeywordProcessor.class);
	
	@Autowired
	private KeywordClient keyClient;
	
	@Override
	public SyncLog process(Adgroups item) throws Exception {
		// TODO Auto-generated method stub
		
		long userId = item.getUserId();
		long adgroupId = item.getAdgroupId();
		
		KeywordsDto keywordDto = keyClient.filterKeywordsByUser(userId, adgroupId);
		
		return Util.convert(keywordDto);
	}
	
}
